[codex] Structure Codex shadow home errors - #3262
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR refactors error handling by replacing a single generic error class with multiple specific error types, improving error structure and messages without changing runtime behavior. The changes are well-tested and low risk. You can customize Macroscope's approvability policy. Learn more. |
Summary
Validation
vp test run apps/server/src/provider/Drivers/CodexHomeLayout.test.tsvp checkvp run typecheckNote
Low Risk
Error-shape and messaging changes only within Codex shadow home setup; behavior on success paths is unchanged and coverage is expanded in unit tests.
Overview
Replaces the single generic
CodexShadowHomeError(detail string + optional cause) with four tagged error types and aSchema.Uniontype: filesystem failures, path conflict (shadow equals shared home), entry conflict (real file blocks symlink), and private-entry symlink (auth.jsonmust not be a symlink).Each failure now carries structured fields (
sharedHomePath,effectiveHomePath,operation,path,entryName,linkPath,targetPath, andPlatformErrorascauseon FS errors). GenerictoShadowHomeError/normalizeShadowHomeErrorwrappers are removed in favor ofEffect.catchTags({ PlatformError })at each FS boundary.Tests assert specific error classes,
matchObjectpayloads, messages, and a new case that FS errors preserve operation and cause when shared home is not a directory.Reviewed by Cursor Bugbot for commit 9765bfc. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace generic
CodexShadowHomeErrorwith structured discriminated error variants inmaterializeCodexShadowHomeCodexShadowHomeErrorclass with a union of four specific error types:CodexShadowHomeFileSystemError,CodexShadowHomePathConflictError,CodexShadowHomeEntryConflictError, andCodexShadowHomePrivateEntrySymlinkError.sharedHomePath,effectiveHomePath,operation,path,cause) and a deterministic message, replacing the previous generic wrapping helperstoShadowHomeErrorandnormalizeShadowHomeError.readLinkState,removePrivateSymlink,ensureSymlink,ensureShadowAuthIsPrivate) are updated to accept structured input objects and return the appropriate specific error type.materializeCodexShadowHomenow receive discriminated error variants instead of a single generic class, requiring callers to handle each variant explicitly.Macroscope summarized 9765bfc.